<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>

<head>
	<sx:head cache="true" />
	<link rel="stylesheet" href="/hrs-intranet/styles/displaytag.css" type="text/css" />
</head>

<s:include value="errorsSection.jsp"></s:include>

<script type="text/javascript">
	function generateReport() {
		// Llamo al action que agrega la accion.
		document.forms[0].action = "MeetingsReportAction";
  		document.forms[0].submit();
	}
	
	function clickOK() {
		document.getElementById('okbtn').click();
	}

	function Func1Delay()
	{
		setTimeout("clickOK()", 100);
	}

	function confirmRemove( url ) 
	{
		if ( confirm("You are about to remove a mentoring meeting. Are you sure you want to continue?") )
		{
			document.forms[0].action = url;
	  		document.forms[0].submit();
		}
	}
</script>

<s:url var="add_action" action="MeetingAction_addMeeting" namespace="/hrs2" />

<%-- <s:label value="%{permissionChecker.hasPermission(permissionNameConverter.getMentoringPlanMeetingPermission(),request.session)}" ></s:label> --%>
<s:form action="MeetingAction_list" cssClass="formClass" id="mentorForm">

	<s:include value="meetingsFilterTags.jsp"></s:include>
		<span class="pageLink" style="position:relative; left:520px; top:40px;" >
<%-- 			<s:if test="hasPermission(permissionNameConverter.getMentoringPlanMeetingPermission())" > --%>
			<s:if test="%{permissionChecker.hasPermission(permissionNameConverter.getMentoringPlanMeetingPermission(),request.session)}">
    			<s:a href="%{#add_action}" ><s:text name="action.plan"/></s:a>
    		</s:if>
			<br><br>
<%-- 			<s:if test="hasPermission(permissionNameConverter.getGenerateMeetingsReportPermission())" > --%>
			<s:if test="%{permissionChecker.hasPermission(permissionNameConverter.getGenerateMeetingsReportPermission(),request.session)}">
				<s:a onclick="generateReport()" cssStyle="cursor:hand" ><s:text name="report.generate"/></s:a>
			</s:if>	
    	</span>
	
	<table width="40%">
		<tr>
			<td width="36%">
				<div id="btnHolder">
					<s:reset type="reset" key="" value="Reset" cssClass="btn"
						cssStyle="position:relative; left:-77px; text-align: center;" onclick="Func1Delay()" />
					<s:submit action="%{actionMethod}" key="button.filter" value="Filter" cssClass="btn"
						id="okbtn" cssStyle="position:relative; left:-175px; top:-28px; text-align: center;" />
				</div>
			</td>
		</tr>
	</table>
	
	<s:if test="%{listModel.size()==0}">
		<s:label key="table.noResult.message" label="" cssClass="formClass"></s:label>
	</s:if>
	<s:else>
		<table width="67%">
			<tr>
				<td colspan="2">
					<display:table id="meetings" name="listModel" requestURI="MeetingAction_list" class="listable" cellpadding="0" cellspacing="0" pagesize="10">
						<display:column property="mentor.person.name" titleKey="mentor" sortable="true" />
						<display:column property="employee.person.name" titleKey="mentee" sortable="true" />
						<display:column property="date" titleKey="meetingDate" sortable="true" format="{0,date,dd/MM/yyyy}" defaultorder="descending"/>
						<display:column property="status" titleKey="status" sortable="true" />
						<display:column property="delayedDays" titleKey="delay" sortable="true" style="text-align: right; color: ${meetings.textColor};" />
<%-- 						<s:if test="hasPermission(permissionNameConverter.getMeetingCheckedByHRPermission())" > --%>
						<s:if test="%{permissionChecker.hasPermission(permissionNameConverter.getMeetingCheckedByHRPermission(),request.session)}">
							<display:column property="checkedByHR" titleKey="checkedByHR" sortable="true" decorator="com.hexacta.hrs.web.util.BooleanTextDecorator"/>
						</s:if>
						<display:column property="onlyCurrentRelationships" titleKey="currentRelationships" sortable="true" decorator="com.hexacta.hrs.web.util.BooleanTextDecorator"/>
						<s:url var="view_action" action="MeetingAction_showDetails" namespace="/hrs2" />
						<s:url var="edit_action" action="MeetingAction_editMeeting" namespace="/hrs2" />
						<s:url var="delete_action" action="MeetingAction_delete" namespace="/hrs2" />
<%-- 						<s:if test="%{hasPermission(permissionNameConverter.getViewMeetingPermission()) || hasPermission(permissionNameConverter.getEditMeetingPermission()) || hasPermission(permissionNameConverter.getDeleteMeetingPermission())}" > --%>
						<s:if test="%{permissionChecker.hasPermission(permissionNameConverter.getViewMeetingPermission(),request.session) || permissionChecker.hasPermission(permissionNameConverter.getEditMeetingPermission(),request.session) || permissionChecker.hasPermission(permissionNameConverter.getDeleteMeetingPermission(),request.session)}">
							<display:column titleKey="options" >
<%-- 								<s:if test="hasPermission(permissionNameConverter.getViewMeetingPermission())" > --%>
								<s:if test="%{permissionChecker.hasPermission(permissionNameConverter.getViewMeetingPermission(),request.session)}">
									<a href="${view_action}?requestId=${meetings.id}"><s:text name="action.view"/></a>&nbsp;&nbsp;&nbsp;
								</s:if>
<%-- 								<s:if test="hasPermission(permissionNameConverter.getEditMeetingPermission())" > --%>
								<s:if test="%{permissionChecker.hasPermission(permissionNameConverter.getEditMeetingPermission(),request.session)}">
									<a href="${edit_action}?requestId=${meetings.id}"><s:text name="action.edit"/></a>&nbsp;&nbsp;&nbsp;
								</s:if>
<%-- 								<s:if test="hasPermission(permissionNameConverter.getDeleteMeetingPermission())" > --%>
								<s:if test="%{permissionChecker.hasPermission(permissionNameConverter.getDeleteMeetingPermission(),request.session)}">
									<a href="javascript:confirmRemove('${delete_action}?requestId=${meetings.id}')"><s:text name="action.remove"/></a>
								</s:if>
							</display:column>
						</s:if>
					</display:table>
				</td>
			</tr>
		</table>
	</s:else>
</s:form>